﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessFacade;
using Comm;
using Entities;

namespace MedicareNoteManagerWeb.Web
{
    public partial class RoleFunction_add : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadDrp();
            }
        }
        public void LoadDrp()
        {
            FillDropDownList("RoleGetlist", "RoleID", "RoleName", "请选择用户组", ddlUser);
            FillDropDownList("MenuGetList", "MenuID", "MenuName", "请选择功能模块", DropRole);
        }
        public string CheckData()
        {
            string strErr = "";

            if (DropRole.SelectedValue == "0")
            {
                strErr += "请选择功能功能模块";
            }
            if (ddlUser.SelectedValue == "0")
            {
                strErr += "请选择功能用户";
            }
            return strErr;
        }
        public void GetModel(sys_roleright_Model model)
        {

                model.RightID = 0;
                model.MenuID = int.Parse(DropRole.SelectedValue);
                model.RoleID = int.Parse(ddlUser.SelectedValue);

        }
        protected void btnOK_Click(object sender, EventArgs e)
        {
            sys_roleright_Model model = new sys_roleright_Model();
            GetModel(model);
            if (!string.IsNullOrEmpty(CheckData()))
            {
                MessageBox.ShowDialog(Page, CheckData(), "error");
                //Response.Write("<script language='javascript' type='text/javascript'>  $.ligerDialog.error('" + CheckData() + "'); </script>");
            }
            if (Busi_sys_Menu.AddMenu(model))
            {

                //Response.Write("<script language='javascript' type='text/javascript'>  $.ligerDialog.success('添加成功！'); </script>");
                MessageBox.ShowDialog(Page, "添加成功！", "success");
            }
            else
            {
                //Response.Write("<script language='javascript' type='text/javascript'>  $.ligerDialog.error('添加失败！'); </script>");
                MessageBox.ShowDialog(Page, "添加失败！", "error");
            }
        }
    }
}